<!-- 新增送修-科室信息 -->
<template>
	<Card>
		<template #head>
			科室信息
		</template>
		<template #body>

			<CellItem ref="CellItem" required @other="onOther" v-model="formData.depId" label="科室名称" itemClickType="select-department"></CellItem>
			<CellField v-model="formData.user" label="科室联系人"></CellField>

			<CellField v-model="formData.phone" label="联系电话"></CellField>
			<CellField required v-model="formData.addr" label="科室地址"></CellField>
			<CellField required v-model="formData.remark" label="故障描述" type="textarea"></CellField>
			<CellField v-model="formData.memo" label="备注" type="textarea"></CellField>



		</template>
	</Card>
</template>

<script>
	import Card from '@/components/card/components/cardBaseWrapper.vue'
	import { getDepartmentData } from '@/apis/common.js'
	export default {
		components: {
			Card,
		},

		data() {
			return {
				formData: {
					depId: '',
					user: '',
					phone: '',
					addr: '',
					remark: '',
					memo: ''
				}

			}
		},

		async mounted() {
			let info = wx.getStorageSync('dept')
			this.formData.depId = info.deptId
			let res = await getDepartmentData(info.deptId)
			this.$refs.CellItem.resetInit(info.deptName)
			if (res.code == 0) {

				this.formData.addr = res.body.deptPlace
			}
		},
		methods: {
			onOther(obj) {
				this.formData.addr = obj.deptPlace || ''
			},
			validate() {
				let msg = ''
				let {
					depId,
					addr,
					remark
				} = this.formData
				if (depId === '') {
					msg = '请选择科室'
				} else if (addr == '') {
					msg = '科室地址不能为空'
				} else if (remark == '') {
					msg = '故障描述不能为空'
				} else {

					msg = ''
				}
				if (!msg) {
					return true
				}
				this.$msg(msg)
				return false


			}
		}
	}
</script>

<style lang="scss" scoped>
	.label {
		&-value {
			display: block;
			font-weight: 400;
			font-size: 28rpx;
			color: #409EFF;
			text-align: right;
		}

		&-content {
			text-align: right;
		}
	}
</style>
